package com.wy.controller;

import com.wy.Service.LouyvService;
import com.wy.pojo.Louyv;
import com.wy.pojo.Reside;
import com.wy.pojo.Room;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/louyv")
@CrossOrigin
public class LouyvController {
    @Resource
    private LouyvService louyvServer;
String msg;
    @GetMapping("/listAll")
    public List<Louyv> search(){
        return louyvServer.searchAll();
    }

    @GetMapping("/list")
    public List<Louyv>seach(Integer resideid){
        return louyvServer.searchidAll(resideid);
    }

    @GetMapping("/delete")
    public String delete(Integer id){
        try{
            louyvServer.del(id);
            msg="删除成功";
        }catch (Exception e){
            msg="删除失败";
        }
        return msg;
    }
    @GetMapping("/add")
    public String add(Louyv louyv){
        try{
            louyvServer.add(louyv);
            msg="添加成功";
        }catch (Exception e){
            msg="添加失败";
        }
        return msg;
    }
}
